class Solution {
public:

    bool myfunction(int* x, int* y)
    {
        return x[0] < y[0];
    }

    int findLongestChain(vector<vector<int>>& pairs)
    {
        int n = pairs.size();
        vector<int> dp(n, 1);
        int ret = 1;
        sort(pairs.begin(), pairs.end());
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (pairs[i][0] > pairs[j][1])
                    dp[i] = max(dp[j] + 1, dp[i]);
            }
            ret = max(ret, dp[i]);
        }


        return ret;

    }
};